package com.lingnan.tijian.mapper;

import com.lingnan.tijian.domain.Orders;
import com.lingnan.tijian.dto.CalendarResponseDto;
import com.lingnan.tijian.dto.OrderDateAndHpnameDto;
import com.lingnan.tijian.dto.OrdersMapperDto;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrdersMapper {
    int deleteByPrimaryKey(Integer orderId);

    int insert(Orders record);

    int insertSelective(Orders record);

    Orders selectByPrimaryKey(Integer orderId);

    int updateByPrimaryKeySelective(Orders record);

    int updateByPrimaryKey(Orders record);

    //来，我们去数据库查询所选医院可以预约的每天的已经约号的数量
    List<CalendarResponseDto> listHospitalAppointmentNumber(List<OrdersMapperDto> ordersMapperDtos);


    @Select("select h.name name,o.orderId orderId,o.orderDate orderDate\n" +
            "from hospital h,orders o\n" +
            "where o.hpId=h.hpId and o.userId=#{userId} and o.state=#{state}")
    List<OrderDateAndHpnameDto> selectByUserIdAndState(Orders orders);

    @Select("select h.name name,o.orderId orderId,o.orderDate orderDate\n" +
            "from hospital h,orders o\n" +
            "where o.hpId=h.hpId and o.userId=#{userId} and o.state=#{state} and o.orderDate=#{orderDate}")
    List<OrderDateAndHpnameDto> selectByUserIdAndStateAndOrderDate(Orders orders);

}